import { Directive, App } from "vue";
import $menusEvent from "./event";

const ContextMenuDirective: Directive = {
  mounted(el, { value, arg, instance }) {
    el.addEventListener("contextmenu", $menusEvent.bind(instance, value));
  },
  unmounted(el, { arg }) {
    el.removeEventListener("contextmenu", $menusEvent);
  },
};

const install = function (app: App) {
  app.directive("menus", ContextMenuDirective);
};

export default install;
